import java.util.Scanner;

/**
 * @author yzh
 * @version 1.0
 * @date 2021/12/21 15:23
 * 成绩排名
 * 算法：字符串
 */
public class _1004 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String n = in.nextLine();
        String s;
        String[][] ans = new String[2][2];
        int max = Integer.MIN_VALUE, min = Integer.MAX_VALUE;
        for (int i = 0; i < Integer.parseInt(n); i++) {
            s = in.nextLine();
            final String[] split = s.split(" ");
            int score = Integer.parseInt(split[2]);
            if (score > max) {
                ans[0][0] = split[0];
                ans[0][1] = split[1];
                max = score;
            }
            if (score < min) {
                ans[1][0] = split[0];
                ans[1][1] = split[1];
                min = score;
            }
        }
        System.out.println(ans[0][0] + " " + ans[0][1]);
        System.out.print(ans[1][0] + " " + ans[1][1]);
    }
}
